package com.sl.au.service.impl;

import com.sl.au.entity.GeoLocation;
import com.sl.au.repository.GeoLocationRepository;
import com.sl.au.service.GeoLocationService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;

@Service("GeoLocationService")
@Transactional
public class GeoLocationServiceImpl extends BaseServiceImpl implements GeoLocationService {
	@Autowired
	GeoLocationRepository geoLocationRepository;

	@Override
	public GeoLocationRepository getGeoLocationRepository() {
		return this.getGeoLocationRepository();
	}

	@Override
	public List<GeoLocation> getGeoLocationPage(int start, int length, String userId, String oderName, String dir) {
		Page<GeoLocation> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = geoLocationRepository.findByUser_Id(userId, pageable);
		return pages.getContent();
	}
}
